package com.aia.ilp.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class EncodeIntercepter extends AbstractInterceptor {

	private static final long serialVersionUID = 1L;
	public String intercept(ActionInvocation ai) throws Exception {
//		String encoding;
//		encoding = ServletActionContext.getRequest().getCharacterEncoding();
//		logger.debug("Before EncodeIntercepter, getRequest().getCharacterEncoding()=" + encoding);
//        debugString("before");
//		
//		
//		ServletActionContext.getRequest().setCharacterEncoding("UTF-8");
//		encoding = ServletActionContext.getRequest().getCharacterEncoding();
//		logger.debug("After EncodeIntercepter, getRequest().getCharacterEncoding()=" + encoding);
//		debugString("after");

		return ai.invoke();
	}

	private void debugString(String d) {
//		String s = ServletActionContext.getRequest().getParameter("CFG_VALUE");
//		if (!StringUtils.isEmpty(s)) {
//			logger.debug(d + " >> EncodeIntercepter>> CFG_VALUE 1.=" + s);
//			try {
//				String s2 = new String(s.getBytes("GBK"),"UTF-8");
//				logger.debug(d + " >> EncodeIntercepter>> CFG_VALUE 2.=" + s2);
//				
//				String s3 = new String(s.getBytes("ISO8859-1"),"UTF-8");
//				logger.debug(d + " >> EncodeIntercepter>> CFG_VALUE 3.=" + s3);
//			} catch (UnsupportedEncodingException e) {
//				e.printStackTrace();
//			}
//		}

	}
}
